<template>
  <div class="data-wrap">
    <m_Header />
         <div class="swipe">
             <van-image round class="avatar" width="70" height="70" v-if="storeInfo.avatar" :src="storeInfo.avatar || ''" />
             <van-image round class="avatar" width="70" height="70" v-else src="https://img.yzcdn.cn/vant/cat.jpeg" />
             <div class="title" v-if="storeInfo.title">{{ storeInfo.title || '' }}</div>
         </div>
         <van-cell-group style="margin-top: 5px">
           <van-cell title="店铺状态">
              <div slot="right-icon">
                <van-switch v-model="state" @input="getState"  active-color="#01B26A" size="14px" />
              </div>
            </van-cell>
            <van-cell title="我的店铺等级" :value="storeInfo.vip + '级'" @click="getUpgrade" />
            <van-cell title="门店信息" is-link />
            <van-cell title="我要提现" is-link />
            <van-cell title="自动接单">
              <div slot="right-icon">
                <van-switch v-model="checked" active-color="#01B26A" size="14px" />
              </div>
            </van-cell>
            <van-cell title="修改基本信息" is-link to="/store/mine/setting" />
            <van-cell title="语音播报">
              <div slot="right-icon">
                <van-switch v-model="checked" active-color="#01B26A" size="14px" />
              </div>
            </van-cell>
          </van-cell-group>
        <div class="btn">
        <button class="tips">下单提醒按钮</button>
        </div>
    <m_Footer />
  </div>
</template>

<script>
import m_Header from '@/components/mineStoreHeader.vue'
import m_Footer from '@/components/mineStoreFooter.vue'
import { Notify } from 'vant';

export default {
  name: 'data',
  data() {
    return {
      state: null,
      checked: true,
      storeInfo: null,
    };
  },
  created(){
    this.storeInfo = this.global.state.storeInfo;
    this.state = this.global.state.storeInfo.status == 'Normal' ? true : false;
  },
  mounted(){
    
  },
  methods:{
    getState(){
      this.axios.post('/api/store/manager/status',{
        token: this.global.state.accessToken,
        status: this.state ? 'Normal' : 'Closed'
      }).then(res=>Notify({type:'success',background: '#07c160',message:res.data.message})).catch(err=>Notify({type:'error',message:'修改失败'}))
    },
    getUpgrade(){
      this.axios.post('/api/store/manager/upgrade/a',{
        token: this.global.state.accessToken,
        status: this.state ? 'Normal' : 'Closed'
      }).then(res=>Notify({type:'success',background: '#07c160',message:res.data.message})).catch(err=>Notify({type:'error',message:'修改失败'}))
    }
  },
  components:{
    m_Header,
    m_Footer
  }
}
</script>
<style scoped>
  .swipe{width:100%;height:150px;margin:auto; background:url(https://p.ssl.qhimg.com/dm/364_207_/t017f4dea4b29278368.jpg) center;position: relative;}
  .swipe .avatar {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    z-index: 2;
    transform: translate(-50%,-50%)
  }
  .swipe .title {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 15px;
    width: 100%;
    text-align: center;
    z-index: 2;
    color: white;
    font-size: 16px;
  }
  .swipe img{width:100%;height:150px;}
  .list{background:white;width:100%;height:40px;border-top:1px solid #ccc;}
  .name{width:40%;height:40px;margin-left:7%;line-height:40px;float:left}
  .img{width:15%;height:40px;margin-left:30%;float:left}
  .img_inco{width:100%;height:40px;line-height:40px;text-align:right}
  .switching{margin-top:7px;margin-left:9px}
  .tips{width:100%;height:45px;color:white;line-height:45px;text-align:center;font-size:16px;border:none}

</style>
